package com.example;
import org.flowable.engine.ProcessEngine;
import org.flowable.engine.ProcessEngineConfiguration;
import org.flowable.engine.ProcessEngines;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * 本地数据库
 * @author wsl
 */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class FlowableLocalDb {

    public ProcessEngine processEngine;

    @BeforeEach
    public void before(){
        ProcessEngineConfiguration configuration = new StandaloneProcessEngineConfiguration();
        configuration.setJdbcDriver("com.mysql.cj.jdbc.Driver");
        configuration.setJdbcUsername("root");
        configuration.setJdbcPassword("123456");
        configuration.setJdbcUrl("jdbc:mysql://localhost:3306/t_flowable?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true");
        configuration.setDatabaseSchemaUpdate("true");
        processEngine = configuration.buildProcessEngine();
    }

//    @Test
//    public void t() {
//        ProcessEngine processEngine = configuration.buildProcessEngine();
//        System.out.println("processEngine：" + processEngine);
//        processEngine.getRepositoryService()
//                .createDeployment()
//                .addClasspathResource("bpmn/Leave.bpmn")
//                .deploy();
//    }

//    @Test
//    public void t1() {
//        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
//        RepositoryService repositoryService = processEngine.getRepositoryService();
//        repositoryService.createDeployment()
//                .addClasspathResource("出差申请流程.bpmn20.xml")
//                .deploy();
//
//    }
}
